#!/usr/bin/env python

import sys, os   
import struct   
  
def recv():   
    buf = sys.stdin.read(2)   
    if len(buf) == 2:   
        (sz, ) = struct.unpack("!h", buf)   
        payload = sys.stdin.read(sz)   
        return payload   
    else:   
        return None  
  
def send(payload):   
    sz = len(payload)   
    header= struct.pack("!h", sz)   
    return sys.stdout.write( header + payload )   
  
def twice(arg1):   
    return 2*arg1   
  
def sum(arg1,arg2):   
    return arg1+arg2   
  
def main_loop():   
    buf = recv()   
    while buf:   
        xa = struct.unpack("!%dB" % len(buf), buf)   
        if xa[0] == 1:   
            calc_res = twice(xa[1])   
        elif xa[0] == 2:   
            calc_res = sum(xa[1], xa[2])   
        result = struct.pack('!B', calc_res)   
        send(result)   
        buf = recv()   
    return None  
  
if __name__ == '__main__':   
    main_loop()  
    